<!--
 * @Description: 工程评估
 * @Author: wangwangwang
 * @Date: 2020-08-17 15:52:58
 * @LastEditors: wangwangwang
 * @LastEditTime: 2020-08-18 17:32:11
-->
<template>
  <div class="pages_content table projectAssess">
    <!-- 评估登记 -->
    <div slot="title" class="dialog-title" style="font-size:24px;padding-top:20px;text-align:center;">工程评估登记</div>
    <div class="dialoginfo">
      <div class="form-container">
        <div class="form-title">工程基本信息</div>
        <el-form ref="projectForm" :model="projectForm" label-width="130px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="工程名称" prop="projectName" :rules="[
                    {
                      required: true,
                      message: '请输入工程名称',
                      trigger: 'blur',
                    },
                  ]">
                <el-input v-model="projectForm.projectName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="地理位置" prop="place" :rules="[
                    {
                      required: true,
                      message: '请输入地理位置',
                      trigger: 'blur',
                    },
                  ]">
                <el-input v-model="projectForm.place"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="施工单位" prop="roadworkId" :rules="[
                    {
                      required: true,
                      message: '请输入施工单位',
                      trigger: 'blur',
                    },
                  ]">
                <el-select v-model="projectForm.roadworkId" placeholder="请选择" style="width:480px;">
                  <el-option v-for="(item, index) in roadworkIdList" :key="index" :label="item.name" :value="item.id"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="建设单位" prop="constructionUnit" :rules="[
                    {
                      required: true,
                      message: '请输入建设单位',
                      trigger: 'blur',
                    },
                  ]">
                <el-input v-model="projectForm.constructionUnit"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="工程性质" prop="projectProperty" :rules="[
                    {
                      required: true,
                      message: '请选择工程性质',
                      trigger: 'blur',
                    },
                  ]">
                <el-select ref="selection0" v-model="projectForm.projectPropertyId" placeholder="请选择" style="width:480px;" @change="$nextTick(()=>{projectForm.projectProperty = $refs.selection0.selectedLabel})">
                  <el-option v-for="(item, index) in typeIdList" :key="index" :label="item.itemName" :value="item.id"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item prop="operationMode" :rules="[
                    {
                      required: true,
                      message: '请选择运作模式',
                      trigger: 'blur',
                    },
                  ]" label="运作模式">
                <el-select ref="selection1" v-model="projectForm.operationModeId" placeholder="请选择" style="width:480px;" @change="$nextTick(()=>{projectForm.operationMode = $refs.selection1.selectedLabel})">
                  <el-option v-for="(item, index) in operationModeList" :key="index" :label="item.itemName" :value="item.id"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item prop="supplyCentre" :rules="[
                    {
                      required: true,
                      message: '请输入拟供应站点',
                      trigger: 'blur',
                    },
                  ]" label="拟供应站点">
                <el-input v-model="projectForm.supplyCentre"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item prop="haulDistance" :rules="[
                    { required: true, message: '请输入运距', trigger: 'blur' },
                  ]" label="运距">
                <el-input v-model="projectForm.haulDistance"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item prop="capitalSource" :rules="[
                    {
                      required: true,
                      message: '请输入资金来源',
                      trigger: 'blur',
                    },
                  ]" label="资金来源">
                <el-select ref="selection1" v-model="projectForm.capitalSource" placeholder="请选择" style="width:397.33px;">
                  <el-option v-for="(item, index) in capitalSourceList" :key="index" :label="item.itemName" :value="item.id"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item prop="advanceFund" :rules="[
                    {
                      required: true,
                      message: '请输入垫资测算',
                      trigger: 'blur',
                    },
                  ]" label="垫资测算">
                <el-input v-model="projectForm.advanceFund"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item prop="continueMoney" :rules="[
                    {
                      required: true,
                      message: '请输入承接价值',
                      trigger: 'blur',
                    },
                  ]" label="承接价值">
                <el-input v-model="projectForm.continueMoney"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="预估用砼量" prop="estimateNum" :rules="[
                    {
                      required: true,
                      message: '请输入预估用砼量',
                      trigger: 'blur',
                    },
                  ]" class="FZYdanWei">
                <el-input v-model="projectForm.estimateNum"></el-input>
                <font>方</font>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item prop="estimatePrices" :rules="[
                    {
                      required: true,
                      message: '请输入预估单价',
                      trigger: 'blur',
                    },
                  ]" label="预估单价" class="FZYdanWei">
                <el-input v-model="projectForm.estimatePrices"></el-input>
                <font>元/方</font>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item prop="estimateCost" :rules="[
                    {
                      required: true,
                      message: '请输入预估成本位',
                      trigger: 'blur',
                    },
                  ]" label="预估成本" class="FZYdanWei">
                <el-input v-model="projectForm.estimateCost"></el-input>
                <font>元</font>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="施工工期" style="width: 520px">
                <el-date-picker v-model="beginTimeFinishTime" type="datetimerange" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="挂靠单位">
                <el-input v-model="projectForm.attachedUnits"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="工程现场特性描述">
                <el-input v-model="projectForm.sceneDescription"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :span="12">
              <el-form-item v-if="UserInfo.adminStatus == 1" prop="createUserId" :rules="[
                    {
                      required: true,
                      message: '请选择负责人',
                      trigger: 'blur',
                    },
                  ]" class="FZYdanWei">
                <span slot="label">负责人</span>
                <el-cascader ref="getCheckedNodes" v-model="projectForm.createUserId" style="width:320px;" :options="principalarr" :show-all-levels="false" :props="{ value: 'id', label: 'name' }" :placeholder="createUserName"></el-cascader>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="hr" style="margin-bottom:10px;"></div>
          <div class="form-title">施工单位情况</div>
          <el-row>
            <el-col :span="12">
              <el-form-item label="成立时间" prop="roadworkEnrollTime" :rules="[
                    {
                      required: true,
                      message: '请输入成立时间',
                      trigger: 'blur',
                    },
                  ]">
                <el-date-picker v-model="projectForm.roadworkEnrollTime" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="注册资本" prop="roadworkEnrollFund" :rules="[
                    {
                      required: true,
                      message: '请输入注册资本',
                      trigger: 'blur',
                    },
                  ]">
                <el-input v-model="projectForm.roadworkEnrollFund" style="width: 100%"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="出资结构" prop="roadworkRatioInvestments" :rules="[
                    {
                      required: true,
                      message: '请输入出资结构',
                      trigger: 'blur',
                    },
                  ]">
                <el-input v-model="projectForm.roadworkRatioInvestments" style="width: 100%"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="经营地址" prop="roadworkBusinessAddress" :rules="[
                    {
                      required: true,
                      message: '请输入经营地址',
                      trigger: 'blur',
                    },
                  ]">
                <el-input v-model="projectForm.roadworkBusinessAddress"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="注册地" prop="roadworkDomicile" :rules="[
                    {
                      required: true,
                      message: '请输入注册地',
                      trigger: 'blur',
                    },
                  ]">
                <el-input v-model="projectForm.roadworkDomicile"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item prop="roadworkPledgeStatus" :rules="[
                  {
                    required: true,
                    message: '请输入抵押情况',
                    trigger: 'blur',
                  },
                ]">
              <span slot="label">抵押情况</span>
              <el-col :span="5">
                <el-radio v-model="projectForm.roadworkPledgeStatus" :label="0">无</el-radio>
                <el-radio v-model="projectForm.roadworkPledgeStatus" :label="1">有</el-radio>
              </el-col>
              <el-col :span="19">
                <el-input v-model="projectForm.roadworkPledge"></el-input>
              </el-col>
            </el-form-item>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item prop="roadworkLitigationStatus" :rules="[
                    {
                      required: true,
                      message: '请输入涉诉情况',
                      trigger: 'blur',
                    },
                  ]">
                <span slot="label">涉诉情况</span>
                <el-col :span="5">
                  <el-radio v-model="projectForm.roadworkLitigationStatus" :label="0">无</el-radio>
                  <el-radio v-model="projectForm.roadworkLitigationStatus" :label="1">有</el-radio>
                </el-col>
                <el-col :span="19">
                  <el-input v-model="projectForm.roadworkLitigation"></el-input>
                </el-col>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item prop="roadworkRun" label="运营情况" :rules="[
                  {
                    required: true,
                    message: '请输入运营情况',
                    trigger: 'blur',
                  },
                ]">
              <el-input v-model="projectForm.roadworkRun"></el-input>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item prop="roadworkHistoryCooperation" :rules="[
                  {
                    required: true,
                    message: '请输入合作情况',
                    trigger: 'blur',
                  },
                ]">
              <span slot="label">合作情况</span>
              <el-col :span="5">
                <el-radio v-model="projectForm.cuLitigationStatus" :label="0">无</el-radio>
                <el-radio v-model="projectForm.cuLitigationStatus" :label="1">有</el-radio>
              </el-col>
              <el-col :span="19">
                <el-input v-model="projectForm.roadworkHistoryCooperation"></el-input>
              </el-col>
            </el-form-item>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item prop="cuLitigationStatus" :rules="[
                    {
                      required: true,
                      message: '请输入涉诉情况',
                      trigger: 'blur',
                    },
                  ]">
                <span slot="label">涉诉情况</span>
                <el-col :span="5">
                  <el-radio v-model="projectForm.cuLitigationStatus" :label="0">无</el-radio>
                  <el-radio v-model="projectForm.cuLitigationStatus" :label="1">有</el-radio>
                </el-col>
                <el-col :span="19">
                  <el-input v-model="projectForm.cuLitigation"></el-input>
                </el-col>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item prop="roadworkBusinessPotential" label="经营潜力" :rules="[
                  {
                    required: true,
                    message: '请输入经营潜力',
                    trigger: 'blur',
                  },
                ]">
              <el-input v-model="projectForm.roadworkBusinessPotential"></el-input>
            </el-form-item>
          </el-row>
          <div class="hr" style="margin-bottom:10px;"></div>
          <div class="form-title">建设单位情况</div>
          <el-row>
            <el-col :span="12">
              <el-form-item prop="cuEnrollTime" :rules="[
                    {
                      required: true,
                      message: '请输入成立时间',
                      trigger: 'blur',
                    },
                  ]">
                <span slot="label">成立时间</span>
                <el-date-picker v-model="projectForm.cuEnrollTime" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item prop="cuEnrollFund" :rules="[
                    {
                      required: true,
                      message: '请输入注册资本',
                      trigger: 'blur',
                    },
                  ]">
                <span slot="label">注册资本</span>
                <el-input v-model="projectForm.cuEnrollFund"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="出资结构" prop="cuRatioInvestments" :rules="[
                    {
                      required: true,
                      message: '请输入出资结构',
                      trigger: 'blur',
                    },
                  ]">
                <el-input v-model="projectForm.cuRatioInvestments" style="width: 100%"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="经营地址" prop="cuBusinessAddress" :rules="[
                    {
                      required: true,
                      message: '请输入经营地址',
                      trigger: 'blur',
                    },
                  ]">
                <el-input v-model="projectForm.cuBusinessAddress"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="注册地" prop="cuDomicile" :rules="[
                    {
                      required: true,
                      message: '请输入注册地',
                      trigger: 'blur',
                    },
                  ]">
                <el-input v-model="projectForm.cuDomicile"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item prop="cuPledgeStatus" :rules="[
                  {
                    required: true,
                    message: '请输入抵押情况',
                    trigger: 'blur',
                  },
                ]">
              <span slot="label">抵押情况</span>
              <el-col :span="5">
                <el-radio v-model="projectForm.cuPledgeStatus" :label="0">无</el-radio>
                <el-radio v-model="projectForm.cuPledgeStatus" :label="1">有</el-radio>
              </el-col>
              <el-col :span="19">
                <el-input v-model="projectForm.cuPledge"></el-input>
              </el-col>
            </el-form-item>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item prop="cuLitigationStatus" :rules="[
                    {
                      required: true,
                      message: '请输入涉诉情况',
                      trigger: 'blur',
                    },
                  ]">
                <span slot="label">涉诉情况</span>
                <el-col :span="5">
                  <el-radio v-model="projectForm.cuLitigationStatus" :label="0">无</el-radio>
                  <el-radio v-model="projectForm.cuLitigationStatus" :label="1">有</el-radio>
                </el-col>
                <el-col :span="19">
                  <el-input v-model="projectForm.cuLitigation"></el-input>
                </el-col>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item prop="cuBusinessPotential" label="经营潜力" :rules="[
                  {
                    required: true,
                    message: '请输入经营潜力',
                    trigger: 'blur',
                  },
                ]">
              <el-input v-model="projectForm.cuBusinessPotential" style="width: 100%"></el-input>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item prop="cuTheCityIsDevelopment" label="开发情况" :rules="[
                  {
                    required: true,
                    message: '请输入在本市开发情况',
                    trigger: 'blur',
                  },
                ]">
              <el-input v-model="projectForm.cuTheCityIsDevelopment" style="width: 100%"></el-input>
            </el-form-item>
          </el-row>
        </el-form>
        <div class="hr" style="margin-bottom:10px;"></div>
        <div class="form-title" style="margin-bottom:10px;">关键项梳理</div>
        <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="projectFormData" tooltip-effect="dark">
          <el-table-column prop="name" label="关键项" width="220"></el-table-column>
          <el-table-column label="梳理结果">
            <template slot-scope="scope">
              <el-input v-model="projectForm[scope.row.value]" style="width: 100%"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button class="bottom_all" type="primary" @click="submitprojectForm('projectForm')">提交审核</el-button>
    </span>
  </div>
</template>

<script>
import mixin from "@/mixins/ICPSmixin.js";
import {
  saveOrUpdate,
} from "@/api/internetSales/projectAssess.js";
import { queryAllByCompanyId } from "@/api/internetSales/chanceManagement.js";
import { orgUserTree } from "@/api/common.js";
import { getUserInfo } from "@/utils/auth.js";
import { getDicType } from "@/api/common.js";
export default {
  mixins: [mixin],
  data() {
    return {
      UserInfo: "",
      principalarr: [],
      createUserName: "",
      beginTimeFinishTime: [],
      roadworkIdList: [],
      /*表单页类型，0为无树状，1为有树状，有树状在el-main加上display:flex*/
      projectFormData: [
        { name: "合同甲方", value: "firstParty" },
        { name: "商务价格", value: "businessPrice" },
        { name: "合同额度", value: "contractAmount" },
        { name: "甲供（卖）材料、周转材料代管约定", value: "appoint" },
        { name: "计量", value: "measure" },
        { name: "结算", value: "settleAccounts" },
        { name: "发票出具", value: "invoice" },
        { name: "付款办法", value: "paymentMethod" },
        { name: "保证金", value: "earnestMoney" },
        { name: "资料交付条件", value: "conditions" },
        { name: "供应保障责任", value: "supplyGuarantee" },
        { name: "质量及技术要求", value: "technicalRequirements" },
        { name: "预期结算及支付制约条款", value: "payTeraty" },
        { name: "停工缓建约定", value: "lockoutTreaty" },
        { name: "争议解决方式", value: "disputeResolution" },
        { name: "其他关键条款", value: "otherKeyTerms" },
      ],
      projectForm: {
        roadworkPledgeStatus: 0,
        roadworkLitigationStatus: 0,
        cuPledgeStatus: 0,
        cuLitigationStatus: 0
      },
      typeIdList: [],
      operationModeList: [],
      capitalSourceList: [
        { itemName: '财政预算投资', id: 1 },
        { itemName: '自筹资金投资', id: 2 },
        { itemName: '银行贷款投资', id: 3 },
        { itemName: '利用外资', id: 4 },
        { itemName: '利用有价证券', id: 5 },],
    };
  },
  async created() {
    this.UserInfo = getUserInfo();
    this.principalarr = await orgUserTree();
    queryAllByCompanyId().then((res) => {
      this.roadworkIdList = res.data
    })
    this.projectForm.projectName = this.$route.query.projectName
    this.projectForm.roadwork = this.$route.query.roadwork
    this.projectForm.place = this.$route.query.place
    this.projectForm.constructionUnit = this.$route.query.constructionUnit
    this.projectForm.engineeringManagementId = this.$route.query.id;
    this.projectForm.roadworkId = this.$route.query.roadworkId
    getDicType({ code: "EngineeringNature" }).then((res) => {
      this.typeIdList = res.data.items;
    });
    getDicType({ code: "operationMode" }).then((res) => {
      this.operationModeList = res.data.items;
    });
  },
  methods: {
    //工程评估登记-提交
    submitprojectForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.projectForm.roadwork = this.roadworkIdList.find((
            obj
          ) => {
            return obj.id == this.projectForm.roadworkId;
          }).name;
          if (this.projectForm.id == undefined) {
            this.projectForm["id"] = "";
          }
          if (this.beginTimeFinishTime != undefined) {
            this.projectForm.beginTime = this.beginTimeFinishTime[0];
            this.projectForm.finishTime = this.beginTimeFinishTime[1];
          }
          if (this.UserInfo.adminStatus == 0) {
            this.projectForm.companyId = this.UserInfo.companyId
            this.projectForm.company = this.UserInfo.companyName
            this.projectForm.organizationId = this.UserInfo.organizationId
            this.projectForm.createUserId = this.UserInfo.userId
            this.projectForm.createUserName = this.UserInfo.userRealName
          } else {
            let size = this.$refs.getCheckedNodes.getCheckedNodes()[0].path.length
            this.fromDate.companyId = this.$refs.getCheckedNodes.getCheckedNodes()[0].path[0]
            this.fromDate.company = this.$refs.getCheckedNodes.getCheckedNodes()[0].pathLabels[0]
            this.fromDate.organizationId = this.fromDate.salesmanId[size - 2]
            this.fromDate.createUserId = this.fromDate.salesmanId[size - 1]
            this.fromDate.userRealName = this.$refs.getCheckedNodes.getCheckedNodes()[0].label
          }
          // console.log(JSON.parse(JSON.stringify(this.projectForm)))
          // console.log(saveOrUpdate);
          saveOrUpdate(this.projectForm).then(() => { });
        } else {
          return false;
        }
      });
    },
  },
};
</script>

<style lang="scss">
.pages_content {
  overflow: auto;
}
.projectAssess {
  .el-input.is- .el-input__inner {
    color: #000;
  }
  .el-select {
    width: 300px;
  }
  .score-container {
    border: 1px solid #e1e5ed;
    .score-list {
      border-bottom: 1px solid #e1e5ed;
      height: 48px;
    }
    .score-list:last-child {
      border: none;
    }
  }
  .score-title {
    margin-bottom: 10px;
  }
  .FZYdanWei {
    > div {
      display: flex;
      font {
        flex: none;
        width: 60px;
        text-align: center;
      }
    }
  }
  .FZYform {
    position: relative;
    label {
      width: 100%;
    }
    .FZYspan1 {
      position: absolute;
      top: 0px;
      right: 300px;
    }
    .FZYspan2 {
      position: absolute;
      top: 0px;
      right: 10px;
    }
    .FZYradio1 {
      position: absolute;
      top: 0px;
      left: 10px;
    }
    .FZYradio1 {
      position: absolute;
      top: 10px;
      left: 90px;
    }
    .FZYradio2 {
      position: absolute;
      top: 10px;
      left: 180px;
    }
  }
}
</style>
